<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%-- remove the .tiles from url, and add the .tiles in the general-init.js. make the url not subfix .tiles  ===
		such as: change the http://localhost:8081/lemon/#home.tiles to http://localhost:8081/lemon/#home
		make the url clear.
	--%>
	<%--
		<li><a href="javascript:void(0)" url="home.tiles" menuLeft="false">主页</a></li>
		 --%>
		 
		 
		 <%-- --%>
<li><a url="home" menuLeft="false">Home</a></li>		

<li><a href="http://www.google.com" class="accessible">Google</a>
	<ul>
		<li><a href="#" class="accessible">Search</a>
			<ul>
				<li><a href="http://base.google.com" target="_blank">Base</a></li>
				<li><a href="http://code.google.com" target="_blank">Code</a></li>

				<li><a url="news_overview" target="_blank">news</a></li>
			</ul>
			</li>
		<li><a href="http://www.gmail.com" target="_blank">GMail&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></li>
	</ul>
</li>

<li><a href="rss_overview" class="accessible">RSS Test</a>
	<ul>
		<li><a url="rss_overview">RSS Reader</a></li>
		<li><a url="rss_publisher_overview">RSS Publish</a></li>
	</ul>
</li>

<li><a url="test_overview">Paging Test</a></li>

<li><a url="news_overview">News</a></li>
		
<div id="menuJson" class="hidden">
 	<jsp:include page="/goal/menu.action"></jsp:include>
 </div>
 <script>
 // alert($('#menuJson'));
  var data = eval($('#menuJson').text());

function builddata() {
    var source = [];
    var items = [];
    // build hierarchical source.
    for (var i = 0; i < data.length; i++) {
        var item = data[i];
        var label = item["menu_name"];
        var parentid = item["parent_menu_id"];
        var id = item["menu_id"];

        if (items[parentid]) {
            var item = { parentid: parentid, label: label, item: item };
            if (!items[parentid].items) {
                items[parentid].items = [];
            }
            items[parentid].items[items[parentid].items.length] = item;
            items[id] = item;
        }
        else {
            items[id] = { parentid: parentid, label: label, item: item };
            source[id] = items[id];
        }
    }
    return source;
};
// build ul li
function buildUL (parent, items) {
    $.each(items, function () {
        if (this.label) {
            // create LI element and append it to the parent element.
            var li = $("<li>" + this.label + "</li>");
            li.appendTo(parent);
            // if there are sub items, call the buildUL function.
            if (this.items && this.items.length > 0) {
                var ul = $("<ul></ul>");
                ul.appendTo(li);
                buildUL(ul, this.items);
            }
        }
    });
};
var source = builddata();
var ul = $("<ul></ul>");
buildUL(ul, source);	
$("#jqxMenu").append(ul);
 </script>